package com.elite.plugins;

import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Signature;
import org.apache.ibatis.session.ResultHandler;

import java.sql.Connection;
import java.sql.Statement;
import java.util.Properties;

/**
 * type : 你要拦截的类
 * method : 你要拦截方法名
 * args : 你要拦截方法参数
 */
@Intercepts({@Signature(
  type= StatementHandler.class,
  method = "prepare",
  args = {Connection.class, Integer.class})})
public class MyPlugin implements Interceptor {
  private Properties properties = new Properties();


  @Override
  public Object intercept(Invocation invocation) throws Throwable {

    // implement pre processing if need
    Object returnObject = invocation.proceed();
    // implement post processing if need
    return returnObject;
  }

  @Override
  public void setProperties(Properties properties) {
    this.properties = properties;
  }
}